{include file="../common/header"}
<!--页面主要内容-->
<main class="lyear-layout-content">
    <div class="container-fluid p-t-15">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
<!--                    <div class="card-toolbar d-flex flex-column flex-md-row">-->
<!--                        <div class="search-bar ml-md-auto">-->
<!--                            <input type="hidden" name="search_field" id="search-field" value="title" />-->
<!--                            <div class="input-group ml-md-auto">-->
<!--                                <div class="input-group mb-3">-->
<!--                                    <input type="text" id="searchusername" class="form-control" placeholdger="请输入用户名">-->
<!--                                    <div class="input-group-append">-->
<!--                                        <span class="input-group-text" onclick="searchuser()">搜索</span>-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="card-body">

                        <div class="table-responsive">
                            <table class="table table-bordered" id="search_result">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>标题</th>
                                    <th>创建用户</th>
                                    <th>应用名称</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="notes" key="n"}
                                <tr id="{$notes.id}">
                                    <td>{$n}</td>
                                    <td>{$notes.title}</td>
                                    <td>{$notes.username}</td>
                                    <td>{$notes.appname}</td>
                                    <td>{$notes.creattime}</td>
                                    <td>
                                        <div class="btn-group">
                                            <a class="btn btn-xs btn-default" onclick="searchnotes({$notes['id']})" data-toggle="modal" data-target="#exampleModal" title="" data-toggle="tooltip" data-original-title="查看"><i class="mdi mdi-eye"></i></a>
                                            <a class="btn btn-xs btn-default id ajax-get confirm" dataid = "{$notes.id}" onclick="deletenotes(this)" title="" data-toggle="tooltip" data-original-title="删除"><i class="mdi mdi-window-close"></i></a>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        {$page|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
<!--    查看-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h6 class="modal-title" id="exampleModalLabel">笔记信息</h6>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="form-group" >
                        <label for="title">标题</label>
                        <input type="text" class="form-control" id="title" >
                    </div>
                    <div class="form-group" >
                        <label for="content">内容</label>
                        <textarea class="form-control" aria-label="With textarea" id="content" style="height: 200px;"></textarea>
                    </div>
                    <div class="form-group" >
                        <label for="ip">ip</label>
                        <input type="text" class="form-control" id="ip">
                    </div>
                    <div class="form-group" >
                        <label for="username">创建用户</label>
                        <input type="email" class="form-control" id="username" >
                    </div>
                    <div class="form-group" >
                        <label for="appname">应用名称</label>
                        <input type="text" class="form-control" id="appname" >
                    </div>
                    <div class="form-group" >
                        <label for="creattime">创建时间</label>
                        <input type="text" class="form-control" id="creattime" >
                    </div>
                    <div class="form-group" >
                        <label for="updatetime">修改时间</label>
                        <input type="text" class="form-control" id="updatetime" >
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!--End 页面主要内容-->
</div>
</div>
{include file="../common/footer"}
<script>
    function deletenotes(obj){
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        var id = $(obj).attr("dataid");
        $.ajax({
            type: "POST",
            url: "{:url('/admin/notes/delnotes')}",
            data: {
                id: id,
            },
            //dataType: "json",
            success: function (data) {
                setTimeout(function() {
                    l.destroy();
                }, 1e3)
                if (data.code == 200) {
                    $.notify({
                        message: data.msg
                    },{
                        placement: {
                            from: "top",
                            align: "center"
                        },
                        type: 'success'
                    });
                    setTimeout("location.reload();", 2000);
                } else {
                    $.notify({
                        message: data.msg
                    },{
                        placement: {
                            from: "top",
                            align: "center"
                        },
                        // settings
                        type: 'danger'
                    });
                }
            },
        });
    }

    function searchnotes(id){
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        $.ajax({
            type: "POST",
            url: "/admin/notes/searchnotes",
            data: {
                id: id,
            },
            dataType: "json",
            success: function (json) {
                setTimeout(function() {
                    l.destroy();
                }, 1e3)
                if (json.code == 200){
                    $("#appname").val(json.data.appname);
                    $("#content").val(json.data.content);
                    $("#creattime").val(json.data.creattime);
                    $("#ip").val(json.data.ip);
                    $("#title").val(json.data.title);
                    $("#updatetime").val(json.data.updatetime);
                    $("#username").val(json.data.username);
                }else{
                    $.notify({
                        message: data.msg
                    },{
                        placement: {
                            from: "top",
                            align: "center"
                        },
                        // settings
                        type: 'danger'
                    });
                }
            }
        })
    }

</script>

</body>

</html>
